<?php
function nino_contact_pro_create_metadata_table() {
	require_once(ABSPATH . '/wp-admin/includes/upgrade.php');
	global $wpdb;
	$sql = 
	"
	CREATE TABLE IF NOT EXISTS `".$wpdb->prefix."nino_contact_pro` (
	  `id` varchar(255) NOT NULL,
	  `name` varchar(255) NOT NULL,
	  `contentMapJs` text NOT NULL,
	  `contentSettingJs` text NOT NULL,
	  `cssContent` text NOT NULL,
	  `mapContent` text NOT NULL,
	  `settingContent` text NOT NULL,
	  `created` datetime NOT NULL,
	  PRIMARY KEY (`id`)
	) ENGINE=MyISAM DEFAULT CHARSET=utf8;
	";
	dbDelta($sql);
}

function nino_contact_pro_remove_metadata_table() {
	require_once(ABSPATH . '/wp-admin/includes/upgrade.php');
	global $wpdb;
	$sql = "DROP TABLE IF EXISTS `".$wpdb->prefix."nino_contact_pro`";
	$wpdb->query($sql);
}

function nino_contact_pro_get_all() {
	global $wpdb;
	
	$sql = "SELECT * FROM `".$wpdb->prefix."nino_contact_pro`";
	
	$results = $wpdb->get_results($sql);
	
	return $results;
}

function nino_contact_pro_get_contact($formId) {
	global $wpdb;
	
	$form = $wpdb->get_row('SELECT * FROM `'.$wpdb->prefix.'nino_contact_pro` WHERE id="'.$formId.'"');
	
	return $form;
}